package com.finace.money.common.util;

import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.drawable.Drawable;
import android.text.TextUtils;
import android.util.Base64;
import android.view.View;


import com.finace.money.R;

import java.util.Arrays;
import java.util.List;

/**
 * Created by ZHP on 2017/7/27.
 */

public class DrawableUtil {

    /*public static int getSmallChipDrawable(String id) {

        int drawable = 0;
        switch (id) {
            case "10":
                drawable = R.drawable.chip_10;
                break;
            case "100":
                drawable = R.drawable.chip_100;
                break;
            case "1000":
                drawable = R.drawable.chip_1000;
                break;
            case "5000":
                drawable = R.drawable.chip_5000;
                break;
        }
        return drawable;
    }*/


    public static Drawable getNameDrawable(String name) {
        Drawable image = null;
        try {
            int resID = UIUtil.getResources().getIdentifier(name, "drawable", "com.finace.money");
            image = UIUtil.getResources().getDrawable(resID);
        } catch (Exception ignored) {

        }
        return image;
    }

    public static Bitmap stringtoBitmap(String string){
        //将字符串转换成Bitmap类型
        Bitmap bitmap=null;
        try {
            byte[]bitmapArray;
            bitmapArray= Base64.decode(string, Base64.DEFAULT);
            bitmap= BitmapFactory.decodeByteArray(bitmapArray, 0, bitmapArray.length);
        } catch (Exception e) {
            e.printStackTrace();
        }

        return bitmap;
    }

}
